<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            height: 100px;
            border: 1px solid #000;
        }

        p {
            height: 100px;
            background-color: #ff0;
            /* 在多数浏览器上都不支持 */

            /* 相对于浏览器而言的，没有脱离文档流 */
            position: sticky;
            top: 0;
        }
    </style>
</head>

<body>
    <div class="a"></div>
    <div></div>
    <div></div>
    <div></div>
    <p></p>
    <div class="a"></div>
    <div></div>
    <div></div>
    <div></div>
    <div class="a"></div>
    <div></div>
    <div></div>
    <div></div>
</body>

</html>